home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / snip9_91.arc / DSPDTST.C < prev    next >
C/C++ Source or Header  |  1991-09-17  |  2KB  |  94 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <dos.h>
  4. typedef unsigned long dword;
  5.  
  6. #ifdef M_I86      /* Identifier for MSC, Watcom, or ZTC */
  7.  
  8. #ifndef __ZTC__
  9. #include <graph.h>
  10.  
  11. #ifndef __WATCOMC__
  12. #define MK_FP(seg,off) ((void far *)(((dword)(seg)<<16)|(off)))
  13. #endif  /* not Watcom   */
  14.  
  15. #define gotoxy(col,row) _settextposition(row,col)
  16. #define cputs(s) cputs(s "\r\n")
  17. #define cprintf(s) cprintf(s "\r\n")
  18.  
  19. #else   /* if ZTC       */
  20.  
  21. #include <disp.h>
  22. #include <smdefs.h>
  23. #define gotoxy(col,row) d_pos(row,col,0)
  24. #define cputs(s) disp_puts(s "\n")
  25. #define cprintf(s) disp_printf(s "\n")
  26.  
  27. #endif  /* if ZTC       */
  28. #endif  /* if TC        */
  29.  
  30. dword far *bios_time = MK_FP(0x0040,0x006C);
  31. dword time1,time2,time3,time4;
  32.  
  33. main()
  34. {
  35.         int i;
  36.  
  37. #ifdef __ZTC__
  38.         disp_open();
  39. #endif
  40.         time1 = *bios_time;
  41.         for(i = 1; i < 1000; i++)
  42.         {
  43.                 gotoxy(10,5);
  44.                 puts("this is a test.");
  45.                 puts("this is the second line.");
  46.         }
  47.         time1 = *bios_time - time1;
  48.         time2 = *bios_time;
  49.         for(i = 1; i < 1000; i++)
  50.         {
  51.                 gotoxy(10,5);
  52.                 printf("this is a test.\n");
  53.                 printf("this is the second line.\n");
  54.         }
  55.         time2 = *bios_time - time2;
  56.         time3 = *bios_time;
  57.         for(i = 1; i < 1000; i++)
  58.         {
  59. #ifdef __ZTC__
  60.                 disp_move(10,5);
  61. #else
  62.                 gotoxy(10,5);
  63. #endif
  64.                 cputs("this is a test.");
  65.                 cputs("this is the second line.");
  66.         }
  67.         time3 = *bios_time - time3;
  68.         time4 = *bios_time;
  69.         for(i = 1; i < 1000; i++)
  70.         {
  71. #ifdef __ZTC__
  72.                 disp_move(10,5);
  73. #else
  74.                 gotoxy(10,5);
  75. #endif
  76.                 cprintf("this is a test.");
  77.                 cprintf("this is the second line.");
  78.         }
  79.         time4 = *bios_time - time4;
  80.  
  81. #ifdef __ZTC__
  82.         disp_close();
  83. #endif
  84.         printf("\nputs     %10lu clock ticks",time1);
  85.         printf("\nprintf   %10lu clock ticks",time2);
  86. #ifndef __ZTC__
  87.         printf("\ncputs    %10lu clock ticks",time3);
  88.         printf("\ncprintf  %10lu clock ticks",time4);
  89. #else
  90.         printf("\nd_puts   %10lu clock ticks",time3);
  91.         printf("\nd_printf %10lu clock ticks",time4);
  92. #endif
  93. }
  94.